//
//  WQ_HomeController.swift
//  xinlang
//
//  Created by 联创—王增辉 on 2019/3/18.
//  Copyright © 2019年 lcWorld. All rights reserved.
//

import UIKit

private let CellID = "CellID"

class WQ_HomeController: WQ_BaseViewController {


    override func viewDidLoad() {
        super.viewDidLoad()
        navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default)
        tableView?.register(UITableViewCell.self, forCellReuseIdentifier: CellID)
    }
    
}
//MARK:- tableView 代理
extension WQ_HomeController
{
    
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: CellID, for: indexPath)
        guard let item = dataSource[indexPath.row] as? WQ_Home_timelineModel else {
            
            return cell
        }
        
        cell.textLabel?.text = item.text
        return cell
    }
    
}
//MARK:- 数据加载
extension WQ_HomeController{
    //加载数据
    override func loadData() {
        
        WQ_NetworkManager<[WQ_Home_timelineModel]>().HomeListRrquest{ (respont) in
            print(respont)
            for item in respont.data ?? [] {
                self.dataSource.append(item)
            }
//            self.dataSource += respont.data
            self.tableView?.reloadData()
            self.isUpLoad = false
        }
        
//        if isUpLoad {
//            DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 2) {
//                for i in (1 ..< 20).reversed() {
//                    self.dataSource.append("\(i) ==")
//                }
//                self.tableView?.reloadData()
//                self.isUpLoad = false
//            }
//        }else{
//            DispatchQueue.main.asyncAfter(wallDeadline: DispatchWallTime.now() + 2) {
//                for i in 1 ..< 20 {
//                    self.dataSource.append("\(i)")
//                }
//                self.refresh?.endRefreshing()
//                self.tableView?.reloadData()
//            }
//        }
        
    }
}
